//**************************************************
//	Digit Widgets Spiral Module
// 	Object Spiral Manipulation 
//	Made to be called from Hyperlinked Digit_Widgets Script
//
// Version 3.0 - 09/12/01 - Added Animation Script to Widgets
//	Version 3.1 - 09/15/01 - Updated with Advanced and Standard Animation Scripts
//**************************************************
<zscriptinsert,"Digit_Widgets_Common_Std.txt">
[PD]
[FontSetColor,255,200,0]Stroke Object Functions[FontSetColor,160,160,160]
[PD]
[VarDef,numpts,0]
[VarDef,Minh,0]
[VarDef,Maxh,0]
[VarDef,Minv,0]
[VarDef,Maxv,0]
[VarDef,MaxDeltaH,0]
[VarDef,MaxDeltaV,0]
[VarDef,cnt,0]
[VarDef,ox,0]
[VarDef,oy,0]
[VarDef,ex,0]
[VarDef,ey,0]
[VarDef,Sdist,0]
[VarDef,ssize,0]
[VarDef,Zinit,0]
[VarDef,zfinis,0]
[VarDef,zdelta,0]
[VarDef,zsize,0]
[VarDef,Zorigin,0]
[VarDef,ztmp,0]
[VarDef,ScurrZ,0]
[VarDef,dangle,0]
[VarDef,SelTool]
[VarDef,Mrk1,1]
[VarDef,Mrk2,2]
[VarDef,mcntr,0]
[VarDef,mptr,1]
[VarDef,pixolz,0]
[VarDef,pixcnt,0]
[iSlider,"SizeIncr",0,1,0,360,"Select Size ",[VarSet,ssize,zscript:SizeIncr],0,[TextCalcWidth,SizeIncr4123]]
[iSlider,"ZStart",0,1,-4000,4000,"Select Starting Z ",[VarSet,Zinit,zscript:ZStart],0,[TextCalcWidth,SizeIncr4123]]
[iSlider,"ZEnd",0,1,-4000,4000,"Select Ending Z ",[VarSet,zfinis,zscript:ZEnd],0,[TextCalcWidth,SizeIncr4123]]
[IButton,"ZPicker ","Pick Zstart and Zend by draggin XYZ Pixol on Canvas",
	[RoutineCall,Mouselook,Hval1,Vval1,Hval2,Vval2,Clicked]
	[RoutineCall,PixolLook,Hval1,Vval1,1,Zval1,dummy,dummy,dummy]
	[Iset,zscript:Zstart,Zval1]
	[VarSet,Zinit,Zval1]
	[RoutineCall,PixolLook,Hval2,Vval2,1,Zval2,dummy,dummy,dummy]
	[Iset,zscript:ZEnd,Zval2]
	[VarSet,Zfinis,Zval2]
]
//[iSlider,"ZTool",0,1,0,11,"Select ZTool ",[VarSet,SelTool,zscript:Ztool],0,[TextCalcWidth,SizeIncr4123]]
[IButton,"ZTool","Set Object that you wish to use",
	[note,"Selecting Tool....",,-1]
	[VarSet,SelTool,[IGet,TOOL:iteminfo]]
	[note,SelTool,,1]
]
[iSwitch,"DepthSizeit",0,"Size to Position",
	[if,zscript:DepthSizeit,
		[ISetStatus,zscript:UserPoint_1,0]
		[ISetStatus,zscript:UserPoint_2,0]
		[IDisable,zscript:Moveto1]
		[IDisable,zscript:Moveto2]
	]
	[if,zscript:RotSizeit,
		[IToggle,zscript:RotSizeit]
	]

] 
[iSwitch,"RotSizeit",0,"Size to UserPoint",
	[if,zscript:RotSizeit,
		[ISetStatus,zscript:UserPoint_1,1]
		[ISetStatus,zscript:UserPoint_2,1]
		[IEnable,zscript:Moveto1]
		[IEnable,zscript:Moveto2]
	]
	[if,zscript:DepthSizeit,
		[IToggle,zscript:DepthSizeit]
	]
] 
//[iSwitch,"UserZ",0,"Use UserPoint to set Z",
//	[if,zscript:UserZ,
//		[Iset,zscript:ZStart,Spointz(0)]
//		[Iset,zscript:ZEnd,Spointz(1)]
//		[VarSet,Zinit,Spointz(0)]
//		[VarSet,Zfinis,Spointz(1)]
//	]
//]

[PD]
[iButton," UserPoint_1 ","Load Current Object Size and Rotation to use in Stroke",
	[TransformGet,SpointX(0),SpointY(0),SpointZ(0),SpointXS(0),SpointYS(0),SpointZS(0),SpointXR(0),SpointYR(0),SpointZR(0)]
//	[if,zscript:UserZ,
//		[Iset,zscript:ZStart,Spointz(0)]
//		[VarSet,Zinit,Spointz(0)]
//	]
,1
]//End Load Point 1

[iButton," Moveto1 ","Load Current Object Position to UserPoint_1",
	[TransformSet,SpointX(0),SpointY(0),SpointZ(0),SpointXS(0),SpointYS(0),SpointZS(0),SpointXR(0),SpointYR(0),SpointZR(0)],1
]

[iButton," UserPoint_2 ","Load Current Object Size and Rotation to use in Stroke",
	[TransformGet,SpointX(1),SpointY(1),SpointZ(1),SpointXS(1),SpointYS(1),SpointZS(1),SpointXR(1),SpointYR(1),SpointZR(1)]
//	[if,zscript:UserZ,
//		[Iset,zscript:ZEnd,Spointz(1)]
//		[VarSet,Zfinis,Spointz(1)]
//	]
,1

]//End Load Point 2

[iButton," Moveto2 ","Load Current Object Position to UserPoint_2",
	[TransformSet,SpointX(1),SpointY(1),SpointZ(1),SpointXS(1),SpointYS(1),SpointZS(1),SpointXR(1),SpointYR(1),SpointZR(1)],1
]
[VarDef,ccntr,0]

[iButton," DoObjStroke ","Look at Stroke Data",
	[VarSet,Zinit,zscript:Zstart]
	[VarSet,Zfinis,zscript:ZEnd]
//	[VarSet,theStroke,[StrokeGetLast]] //get the last drawn stroke
	[VarSet,numpts,[StrokeGetInfo,theStroke,0]]
	[VarSet,Zdelta,Zfinis-Zinit]
	[VarSet,zsize,Zdelta/numpts]
	[VarSet,Zorigin,Zinit]
	[VarSet,Pixcnt,0]

	//[VarSet,Minh,[StrokeGetInfo,theStroke,4]]
	//[VarSet,Maxh,[StrokeGetInfo,theStroke,6]]
	//[VarSet,Minv,[StrokeGetInfo,theStroke,5]]
	//[VarSet,Maxv,[StrokeGetInfo,theStroke,7]]
	//[VarSet,MaxDeltaH,[StrokeGetInfo,theStroke,10]]
	//[VarSet,MaxDeltaV,[StrokeGetInfo,theStroke,11]]

	// got to get how much time the number of iterations are
	[if,[IGet,zscript:RotSizeit],
		[VarSet,mcntr,1.0/numpts]	
		[VarSet,mptr,1]	
		//make sure that this is updated as switch only does it once
//		[if,zscript:UserZ,
//			[Iset,zscript:ZStart,Spointz(0)]
//			[Iset,zscript:ZEnd,Spointz(1)]
//			[VarSet,Zinit,Spointz(0)]
//			[VarSet,Zfinis,Spointz(1)]
//		]
	]
	
	[VarSet,cnt,0]
	//get origin
	[VarSet,ox,[StrokeGetInfo,theStroke,1,0]]
	[VarSet,oy,[StrokeGetInfo,theStroke,2,0]]

	[ISet,Tool:ItemInfo,SelTool]
	
	//put tool on the canvas
	[canvasclick,ox,oy,ox+10,oy+10]
	//Size it accordingly
	[TransformSet,ox,oy,Zorigin,ssize,ssize,ssize]
	[if,[iGet,zscript:DepthSizeit],
		[TransformGet,IcurrX,IcurrY,IcurrZ,IcurrXS,IcurrYS,IcurrZS]
		[RoutineCall,DepthCalc]
	]//Endif
	//snapit
	[IPress,Transform:Snapshot]
	//draw loop distance must be greater than size
	[loop,numpts,
		[VarSet,ex,[StrokeGetInfo,theStroke,1,cnt]]
		[VarSet,ey,[StrokeGetInfo,theStroke,2,cnt]]

		//check distance
		[RoutineCall,GetDistance,ox,ex,oy,ey]
		//make sure does the last one
		[if,Pixcnt > ssize,
			[VarSet,Pixcnt,0]	//reset counter
//		[if,DistToMark>ssize,

			//big enough so put it here
			[TransformSet,ex,ey,Zinit]

			[if,[iGet,zscript:DepthSizeit],
				[TransformGet,IcurrX,IcurrY,IcurrZ,IcurrXS,IcurrYS,IcurrZS]
				[RoutineCall,DepthCalc]
			,//Else
				[if,[IGet,zscript:RotSizeit],
					[VarSet,crecurse,mcntr*mptr]
					[VarSet,resultxs,[Interpolate,crecurse,SpointXS(0),SpointXS(1)]]
					[VarSet,resultys,[Interpolate,crecurse,SpointYS(0),SpointYS(1)]]
					[VarSet,resultzs,[Interpolate,crecurse,SpointZS(0),SpointZS(1)]]
					[VarSet,resultxr,[Interpolate,crecurse,SpointXR(0),SpointXR(1)]]
					[VarSet,resultyr,[Interpolate,crecurse,SpointYR(0),SpointYR(1)]]
					[VarSet,resultzr,[Interpolate,crecurse,SpointZR(0),SpointZR(1)]]
					[TransformSet,,,,resultxs,resultys,resultzs,resultxr,resultyr,resultzr]
				]
			]//Endif

			[IPress,Transform:Snapshot]
			//make this the new start
			[VarSet,ox,ex]
			[VarSet,oy,ey]
			//increment Z 
			[VarSet,ztmp,zsize*cnt]
			[VarSet,Zinit,Zorigin+ztmp]
		]

		//update mptr as we find the next point
		[VarInc,mptr]
		[VarInc,cnt]
		[VarInc,Pixcnt]
	]//endloop
	//make sure end is done	
	[VarSet,ex,[StrokeGetInfo,theStroke,1,numpts]]
	[VarSet,ey,[StrokeGetInfo,theStroke,2,numpts]]
	[TransformSet,ex,ey,Zfinis]
	[IPress,Transform:Snapshot]
]
[iButton," Getstroke ","Grab the Stroke Data",
	[VarSet,theStroke,[StrokeGetLast]] //get the last drawn stroke
	[note,"Stroke Data Taken",,1]
]
[PD]
[pd][penMove,0,8]
<zscriptinsert,"Widgets_Index_Include_Std.txt">
[pd][penMove,0,8]
\C00e0e0About This ZScript:\Cc0c0c0
This script will allow you to procreate a number of objects along a line defined by a brush stroke. First you select the \Cffa000Sizeincr\Cc0c0c0 and then the \Cffa000Starting Z\Cc0c0c0 and \Cffa000Ending Z Value\Cc0c0c0 that you want your object line to span. A \Cffa000ZPicker\Cc0c0c0 is provided to allow you to use your mouse to drag on the canvas to pick up these Z values. 
[PD]
You can have the routine automatically Rotate and Size your objects by setting a \Cffa000User Point 1\Cc0c0c0 and a \Cffa000User Point 2\Cc0c0c0 The routine will use these two points to scale and rotate the object as it moves along the brush stroke. 
[PD]
The next thing to do is to define your brush stroke by selecting a brush and drawing on the canvas from where you want your objects to start to where you want them to end. Then press \Cffa000Getstroke\Cc0c0c0. You can then \Cffa000Cntrl Z\Cc0c0c0 to erase the brush stroke, we don't need it on the canvas. Select the desired object to use in \Cffa000ZTool\Cc0c0c0, a list is provided by pressing \Cffa000Stroke Object Selections\Cc0c0c0 Press \Cffa000DoObjStroke\Cc0c0c0 to activate the routine and it will draw your objects from the Starting XYZ position to the Ending XYZ position following the brush stroke that you made. It will also scale and rotate the objects providing you have set the switches and defined a \Cffa000User Point 1\Cc0c0c0 and a \Cffa000User Point 2\Cc0c0c0  
[PD]
[varDef,theSStroke,(ZObjStrokeV02n464=H64V64H63V65H63V66H62V67H62V68H62V69H62V6AH62V6BH62V6CH62V6DH62V6EH62V6FH62V70H61V70H61V71H61V72H61V73H61V74H61V75H61V76H61V77H61V78H61V79H61V7AH61V7BH61V7CH61V7DH62V7DH62V7EH62V7FH62V80H62V81H62V82H62V83H63V83H63V84H63V85H63V86H64V86H64V87H64V88H64V89H65V8AH65V8BH65V8CH66V8CH66V8DH66V8EH67V8EH67V8FH67V90H68V90H68V91H68V92H69V92H69V93H6AV93H6AV94H6BV94H6BV95H6BV96H6CV96H6DV97H6DV98H6EV98H6EV99H6FV99H6FV9AH70V9AH71V9AH72V9AH72V9BH73V9BH74V9BH74V9CH75V9CH75V9DH76V9DH77V9DH78V9EH79V9EH79V9FH7AV9FH7BV9FH7BVA0H7CVA0H7DVA0H7EVA0H7EVA1H7FVA1H80VA1H81VA1H82VA2H83VA2H84VA2H85VA2H86VA3H87VA3H88VA3H89VA3H8DVA3H90VA3H91VA3H91VA4H92VA4H95VA4H96VA4H97VA4H98VA4H99VA4H9AVA4H9BVA4H9CVA4H9DVA3H9EVA3H9FVA2HA0VA2HA1VA2HA2VA2HA2VA1HA3VA1HA4VA1HA5VA1HA6VA0HA7VA0HA7V9FHA8V9FHA8V9EHA9V9EHA9V9DHAAV9DHAAV9CHABV9BHACV9AHACV99HADV99HADV98HAEV97HAFV96HAFV95HB0V94HB0V93HB1V92HB1V91HB1V90HB1V8FHB1V8EHB1V8DHB1V8CHB1V8BHB0V8BHB0V8AHAFV8AHAFV89HAEV89HADV89HACV89HABV89HAAV89HA9V89HA8V89HA7V89HA6V89HA5V89HA2V89HA1V89HA0V89H9FV89
H9EV89H9DV89H9CV8AH9BV8AH9AV8AH99V8BH98V8CH97V8CH96V8CH96V8DH95V8DH95V8EH94V8EH94V8FH93V8FH93V90H92V90H91V91H90V92H8FV93H8EV94H8DV95H8DV96H8CV96H8CV97H8CV98H8BV99H8BV9AH8AV9BH8AV9CH8AV9DH8AV9EH89V9FH89VA0H89VA1H89VA2H89VA3H89VA4H88VA4H88VA5H88VA6H88VA7H88VA8H88VA9H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HDCVE7HDDVE7HDDVE8HDEVE9HE1VE9HE1VEAHE4VEBHE5VEBHE8VECHE8VEDHE9VEEHEAVEEHEBVEFHECVEFHEDVF0HEEVF1HEFVF2HF0VF2HF1VF3HF2VF3HF3VF3HF4VF4HF5VF4HF6VF4HF7VF4HF7VF5HF8VF5HF9VF5HFCVF5HFFVF6H100VF6H101VF7H102VF7H105VF7H106VF8H107VF8H108VF8H109VF8H10AVF8H10BVF8H10CVF9H10DVF9H10EVF9H10FVF9H110VF9H111VF9H114VF9H115VF9H118VF9H11BVF9H11CVF9H11FVF9H122VF9H123VF9H124VF9H125VF9H126VF9H127VF9H128VF8H129VF8H12AVF8H12BVF8H12CVF8H12DVF8H12EVF8H12FVF7H130VF7H131VF7H132VF6H133VF6H134VF6H134VF5H135VF5H136VF5H137VF5H137VF4H137VF4)]
[iButton,"Example ","Interpolation Widget Example",
	[if,[Ireset],
	[IcolorSet,239,234,30]
	[note,"I will select a Sphere and provide 2 Points that we will connect",zscript:example,2]
	[ISet,Tool:ItemInfo,8]
	[CanvasClick,DocMidX,DocMidY,DocMidX+10,DocMidY+10]
	[IPress,Transform:Move]
	[TransformSet,100,100,0,10,10,10]
	[Note,"Something Here at 100X 100Y 0Z",zscript:example,1]
	[IPress,Transform:Snapshot]
	[TransformSet,DocMidX,DocMidY,-500,30,30,30]
	[note,"And something there at the Middle and -500Z",zscript:example,1]
	[IPress,Transform:Snapshot]
	[Note,"Now I will set the Tool that I will use by selecting the desired object and pressing ZTool, in this case I will keep the sphere",zscript:example,0]
	[Ipress,zscript:ZTool]
	[Note,"Now I want to use a brush and create a brush stroke between the First Object to the Second Object",zscript:example,0]
	[ISet,Draw:DrawSize,5]	
	[Iset,Tool:ItemInfo,2]
	[CanvasStroke,theSStroke]
	[note,"Pressing GetStroke to record it for use",zscript:example,1]
	[IPress,zscript:GetStroke]
	[note,"Now we no longer need the stroke on the canvas I will Cntrl Z it",zscript:example,2]
	[IKeyPress,CTRL+'z']
	[Note,"That takes care of the X&Y Axis. We now have to enter the Z axis. The Start was 0 Z and the End was placed at -500 Z",zscript:example,0]
	[ISet,Zscript:ZStart,0]
	[Note,"Setting ZStart to 0",zscript:example,1]
	[ISet,Zscript:ZEnd,-500]
	[Note,"Setting ZEnd to -500",zscript:example,1]
	[Note,"These values can be set by the mouse using the ZPicker and dragging from Start to End.",zscript:example,0]
	[Note,"For this test we will set the SizeIncr to 20. You can also size you objects to the ZDepthReference or two User Values",zscript:example,0]
	[Iset,zscript:sizeincr,20]
	[Note,"Setting sizeincr to 20",zscript:example,1]
	[note,"Now we will see what happens by pressing DoObjStroke",zscript:example,2]
	[IPress,zscript:DoObjStroke]
	[Note,"Now we will see how you can use two user points to size and rotate the objects as they follow the brush stroke",zscript:example,0]
	[IPress,Layer:Modifiers:Clear]
	[if,[IGet,zscript:RotSizeit],
	,
		[IToggle,zscript:RotSizeit]
	]
	[Note,"Turning RotSizeit Switch ON",zscript:example,2]
	[VarSet,seltool,9]
	[note,"Changing the Tool to a cube",zscript:example,1]
	[ISet,Tool:ItemInfo,9]
	[CanvasClick,DocMidX,333,DocMidX+10,DocMidY+10]
	[IPress,Transform:Move]
	[TransformSet,DocMidX,333,0,10,10,10,0,45,-180]
	[note,"We don't really care about position because it follows the stroke but we will set the starting size to 10 and a starting Rotation - Then we press UserPoint_1 to save start",zscript:example,0]
	[IPress,zscript:UserPoint_1]
	[note,"Pressing UserPoint_1 to save starting size of 10 and Rotation",zscript:example,2]
	[note,"Now we set the Ending Size and Rotation and press UserPoint_2",zscript:example,0]
	[TransformSet,DocMidX,333,-500,30,30,30,45,0,180]
	[IPress,zscript:UserPoint_2]
	[note,"Pressing UserPoint_2 to save Ending Size of 30 and Rotation",zscript:example,2]
	[IPress,Transform:DrawPointer]
	[note,"Now we no longer need the Cube on the canvas I will Cntrl Z it",zscript:example,2]
	[IKeyPress,CTRL+'z']
	[Note,"Now lets Run the Stroke again and see what happens!",zscript:example,0]
	[IPress,zscript:DoObjStroke]
	[Note,"That was easy! Happy Experimenting!",zscript:example,0]
,//else
	[Note,"Aborting! Maybe another day eh?",,3]
]
]

[PD]
[PD]
[fontSetSizeSmall]\C00e0e0Standard Digit Widget Stroke Object Revision 1.0, created by Digits\Cc0c0c0
